package com.zzzy.aspect;


import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Aspect
@Order(-1)
public class LogAspect {

    private final Logger logger = Logger.getLogger(this.getClass());
    private final String POINT_CUT = "execution(* com.zzzy.controller.*.*(..))";

    @Pointcut(POINT_CUT)
    public void pointCut(){}

    public LogAspect(){
        logger.info("-------------------------Init LogAspect---------------");
    }

    @Before(value = "pointCut()")
    public void beforeMethod(JoinPoint jp){
        String methodName = jp.getSignature().getName();
        logger.debug("【前置通知】the method 【" + methodName + "】 begins with " + Arrays.asList(jp.getArgs()));
    }

}
